package org.itboys.core.controller.front.small;

import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
import org.itboys.core.common.SundayCommonConstants;
import org.itboys.core.dto.count.SundayCountDto;
import org.itboys.core.service.mongo.front.SundayFrontCountService;
import org.itboys.core.util.ResponseMessage;
import org.itboys.framework.spring.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 作者：zzq
 * 时间：2018/10/23
 * 描述：结算
 */
@Controller
@RequestMapping("/sunday/small/count")
@Api(value = "count", description = "结算")
public class SundaySmallCountController extends BaseController {
    @Autowired
    private SundayFrontCountService countService;

    @RequestMapping(value = "/countCart", method = {RequestMethod.POST})
    @ApiOperation(value = "结算购物车")
    public void countCart(
            HttpServletRequest request,
            HttpServletResponse response,
            @ApiParam(value = "用户ID") @RequestParam(value = "memberId", required = true) Long memberId,
            @ApiParam(value = "加入购车类型。1,加入购物车，2立即购买加入购物车。") @RequestParam(value = "cartType", required = false) Integer cartType,
            @ApiParam(value = "购物车ID集合(非商品ID)。如：cardIds=1,2,3") @RequestParam(value = "cartIds", required = true) List<Long> cartIds
    ) {
        SundayCountDto result = countService.countCart(memberId, cartIds, cartType,SundayCommonConstants.NO);
        ResponseMessage.success(result);
    }
}
